home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World Komputer 2010 April
/
PCWorld0410.iso
/
pluginy Firefox
/
59193
/
59193.xpi
/
chrome
/
manman89grablink.jar
/
content
/
overlay.js
< prev
next >
Wrap
Text File
|
2010-01-23
|
3KB
|
129 lines
var manman89grablink =
{
upload_selected: function()
{
var text = '';
var textWindow = document.commandDispatcher.focusedWindow;
var node = document.commandDispatcher.focusedElement;
if (node != undefined && node != null){
var nodeLocalName = node.localName.toUpperCase();
if ((nodeLocalName == "TEXTAREA") || (nodeLocalName == "INPUT" && (node.type.toUpperCase() == "TEXT" || node.type.toUpperCase() == "FILE")) || nodeLocalName == "TEXTBOX" ) {
text = node.value.substring(node.selectionStart, node.selectionEnd);
}else{
text = textWindow.getSelection();
}
}else{
text = textWindow.getSelection();
}
window.openDialog(
"chrome://manman89grablink/content/resultDialog.xul",
"Your Link :",
"chrome,modal,dialog,centerscreen,dependent",text);
},
isset_no_url: function(){
var send = false;
var prefs = Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefBranch);
if (prefs.getPrefType("manman89grablink.no_url") == prefs.PREF_BOOL){
send = prefs.getBoolPref("manman89grablink.no_url");
}
return send;
},
go_to_site: function(site_url) {
var myTabRef = getBrowser().addTab(site_url);
getBrowser().selectedTab = myTabRef;
},
set_menu_event: function(event) {
var manman89grablinkmenu = document.getElementById('context-manman89grablink');
manman89grablinkmenu.setAttribute('oncommand', event);
},
set_menu_caption: function(caption) {
var manman89grablinkmenu = document.getElementById('context-manman89grablink');
manman89grablinkmenu.setAttribute('label', caption);
},
GetLinks: function(bSelected) {
var focusedWindow = document.commandDispatcher.focusedWindow;
var focusedDoc = document.commandDispatcher.focusedWindow.document;
var argc = manman89grablink.GetLinks.arguments.length;
var argv = manman89grablink.GetLinks.arguments;
var reMask;
var selLinks = new Array();
var i, j = 0;
if (argc > 1)
reMask = new RegExp(argv[1], 'i');
for (i = 0;i < focusedDoc.links.length;i++) {
if ((!bSelected || focusedWindow.getSelection().containsNode(focusedDoc.links[i], true)) &&
(argc <= 1 || focusedDoc.links[i].href.match(reMask)))
{
selLinks[j] = focusedDoc.links[i].href;
j++;
}
}
return selLinks;
},
EOL: function()
{
platform = navigator.platform.toLowerCase();
if (platform.indexOf('win') != -1)
{
return "\r\n"; //CR LF
}
if (platform.indexOf('mac') != -1)
{
return "\r"; //CR
}
if(platform.indexOf('unix') != -1 || platform.indexOf('linux') != -1 || platform.indexOf('sun') != -1)
{
return "\n"; //LF
}
},
OnCommand: function(cmd)
{
var links;
var i;
switch (cmd) {
case 'all':
links = manman89grablink.GetLinks(false);
break;
case 'sel':
links = manman89grablink.GetLinks(true);
break;
default:
return;
}
if (links.length == 0){return;}
var copytext = '';
var copytext1='';
for (i = 0;i < links.length;i++)
{
copytext += links[i] + manman89grablink.EOL();
if (copytext1.indexOf(links[i]+manman89grablink.EOL())=="-1")
{
copytext1 += links[i] + manman89grablink.EOL();
}
}
copytext=copytext+String.fromCharCode(255)+"<nguyenvanmanscanlink2010>"+String.fromCharCode(255)+copytext1;
window.openDialog(
"chrome://manman89grablink/content/resultDialog.xul",
"Your Link :",
"chrome,modal,dialog,centerscreen,dependent",copytext);
},
};